package com.xiaomi.web.handlers;

import com.github.pagehelper.PageInfo;
import com.xiaomi.domain.OrdersEntity;
import com.xiaomi.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
@Controller
@RequestMapping("admin")
public class OrderHandler {
    @Autowired
    private OrderService orderService;

   @RequestMapping(name = "查看订单",path = "imglist1")
    public String checkOrder(@RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum, Model model){
       if(pageNum==0){
           pageNum=1;
       }
       PageInfo<OrdersEntity> orderspageinfo = orderService.orderPagination(pageNum);
        model.addAttribute("orderspageinfo",orderspageinfo);
       return "admin/imglist1";
   }

   @RequestMapping(name="批量删除订单" , path = "batchDelOrders")
   public String batchDelOrders(String[] ids){
       orderService.batchDelOrders(ids);
       return "redirect:/admin/imglist1";
   }


}
